BEGIN;
CREATE TABLE "REFERENCES_REGION" (
    "ID" integer NOT NULL PRIMARY KEY,
    "CODE" integer NOT NULL CHECK ("CODE" >= 0),
    "NAME" varchar(100) NOT NULL
)
;
CREATE GENERATOR "REFERENCES_REGION_GN"

            CREATE TRIGGER "REFERENCES_REGION_TR" FOR "REFERENCES_REGION"
            BEFORE INSERT
            AS 
            BEGIN
               IF (NEW."ID" IS NULL) THEN 
                   NEW."ID" = GEN_ID("REFERENCES_REGION_GN", 1);
            END
CREATE TABLE "REFERENCES_REQUESTREASON" (
    "ID" integer NOT NULL PRIMARY KEY,
    "REASON" blob sub_type 1 NOT NULL
)
;
CREATE GENERATOR "REFERENCES_REQUESTREASON_GN"

            CREATE TRIGGER "REFERENCES_REQUESTREASON_TR" FOR "REFERENCES_REQUESTREASON"
            BEFORE INSERT
            AS 
            BEGIN
               IF (NEW."ID" IS NULL) THEN 
                   NEW."ID" = GEN_ID("REFERENCES_REQUESTREASON_GN", 1);
            END
CREATE TABLE "REFERENCES_REQUESTANSWER" (
    "ID" integer NOT NULL PRIMARY KEY,
    "ANSWER" blob sub_type 1 NOT NULL
)
;
CREATE GENERATOR "REFERENCES_REQUESTANSWER_GN"

            CREATE TRIGGER "REFERENCES_REQUESTANSWER_TR" FOR "REFERENCES_REQUESTANSWER"
            BEFORE INSERT
            AS 
            BEGIN
               IF (NEW."ID" IS NULL) THEN 
                   NEW."ID" = GEN_ID("REFERENCES_REQUESTANSWER_GN", 1);
            END
CREATE TABLE "REFERENCES_SPECIALISTPOST" (
    "ID" integer NOT NULL PRIMARY KEY,
    "CODE" integer NOT NULL CHECK ("CODE" >= 0),
    "NAME" varchar(100) NOT NULL
)
;
CREATE GENERATOR "REFERENCES_SPECIALISTPOST_GN"

            CREATE TRIGGER "REFERENCES_SPECIALISTPOST_TR" FOR "REFERENCES_SPECIALISTPOST"
            BEFORE INSERT
            AS 
            BEGIN
               IF (NEW."ID" IS NULL) THEN 
                   NEW."ID" = GEN_ID("REFERENCES_SPECIALISTPOST_GN", 1);
            END
CREATE TABLE "REFERENCES_ACADEMICDEGREE" (
    "ID" integer NOT NULL PRIMARY KEY,
    "NAME" varchar(100) NOT NULL,
    "SHORT_NAME" varchar(20) NOT NULL
)
;
CREATE GENERATOR "REFERENCES_ACADEMICDEGREE_GN"

            CREATE TRIGGER "REFERENCES_ACADEMICDEGREE_TR" FOR "REFERENCES_ACADEMICDEGREE"
            BEFORE INSERT
            AS 
            BEGIN
               IF (NEW."ID" IS NULL) THEN 
                   NEW."ID" = GEN_ID("REFERENCES_ACADEMICDEGREE_GN", 1);
            END
CREATE TABLE "REFERENCES_SPECIALISTCATEGORY" (
    "ID" integer NOT NULL PRIMARY KEY,
    "NAME" varchar(100) NOT NULL
)
;
CREATE GENERATOR "REFERENCES_SPECIALISTCAT4D42_GN"

            CREATE TRIGGER "REFERENCES_SPECIALISTCAT4D42_TR" FOR "REFERENCES_SPECIALISTCATEGORY"
            BEFORE INSERT
            AS 
            BEGIN
               IF (NEW."ID" IS NULL) THEN 
                   NEW."ID" = GEN_ID("REFERENCES_SPECIALISTCAT4D42_GN", 1);
            END
CREATE TABLE "REFERENCES_SERVICECATEGORY" (
    "ID" integer NOT NULL PRIMARY KEY,
    "CODE" integer NOT NULL CHECK ("CODE" >= 0),
    "NAME" varchar(200) NOT NULL,
    "PARENT_ID" integer
)
;
CREATE GENERATOR "REFERENCES_SERVICECATEGORY_GN"

            CREATE TRIGGER "REFERENCES_SERVICECATEGORY_TR" FOR "REFERENCES_SERVICECATEGORY"
            BEFORE INSERT
            AS 
            BEGIN
               IF (NEW."ID" IS NULL) THEN 
                   NEW."ID" = GEN_ID("REFERENCES_SERVICECATEGORY_GN", 1);
            END
ALTER TABLE "REFERENCES_SERVICECATEGORY" ADD CONSTRAINT "PARENT_ID_REFS_ID_3C71ED0B" FOREIGN KEY ("PARENT_ID") REFERENCES "REFERENCES_SERVICECATEGORY" ("ID");
CREATE INDEX "REFERENCES_SERVICECATEGORY_F5CC" ON "REFERENCES_SERVICECATEGORY" ("PARENT_ID");
COMMIT;
